<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sentinel LDK Licensing Service</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #34495e;
        }
        input[type="number"] {
            width: 200px;
            padding: 10px;
            border: 2px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
        }
        button {
            background-color: #3498db;
            color: white;
            padding: 12px 24px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            margin-right: 10px;
        }
        button:hover {
            background-color: #2980b9;
        }
        .result {
            margin-top: 20px;
            padding: 15px;
            background-color: #ecf0f1;
            border-radius: 5px;
            white-space: pre-wrap;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            max-height: 500px;
            overflow-y: auto;
            border: 1px solid #bdc3c7;
        }
        .loading {
            color: #f39c12;
            font-style: italic;
        }
        .error {
            color: #e74c3c;
            background-color: #fadbd8;
            border-color: #e74c3c;
        }
        .success {
            color: #27ae60;
            background-color: #d5f4e6;
            border-color: #27ae60;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🔐 Sentinel LDK Licensing Service</h1>
        
        <div class="form-group">
            <label for="featureId">功能ID (Feature ID):</label>
            <input type="number" id="featureId" value="0" min="0">
        </div>
        
        <button onclick="checkLicense()">🔍 检查许可证</button>
        <button onclick="healthCheck()">❤️ 健康检查</button>
        
        <div id="result" class="result" style="display: none;"></div>
    </div>

    <script>
        async function checkLicense() {
            const featureId = document.getElementById('featureId').value;
            const resultDiv = document.getElementById('result');
            
            resultDiv.style.display = 'block';
            resultDiv.className = 'result loading';
            resultDiv.textContent = '正在检查许可证...';
            
            try {
                const response = await fetch(`/api/license/check?featureId=${featureId}`);
                const result = await response.text();
                
                if (response.ok) {
                    resultDiv.className = 'result success';
                    resultDiv.textContent = result;
                } else {
                    resultDiv.className = 'result error';
                    resultDiv.textContent = `错误: ${response.status} - ${result}`;
                }
            } catch (error) {
                resultDiv.className = 'result error';
                resultDiv.textContent = `网络错误: ${error.message}`;
            }
        }
        
        async function healthCheck() {
            const resultDiv = document.getElementById('result');
            
            resultDiv.style.display = 'block';
            resultDiv.className = 'result loading';
            resultDiv.textContent = '正在检查服务状态...';
            
            try {
                const response = await fetch('/api/license/health');
                const result = await response.text();
                
                if (response.ok) {
                    resultDiv.className = 'result success';
                    resultDiv.textContent = `✅ ${result}`;
                } else {
                    resultDiv.className = 'result error';
                    resultDiv.textContent = `❌ 服务异常: ${response.status}`;
                }
            } catch (error) {
                resultDiv.className = 'result error';
                resultDiv.textContent = `❌ 网络错误: ${error.message}`;
            }
        }
        
        // 页面加载时自动执行健康检查
        window.onload = function() {
            healthCheck();
        };
    </script>
</body>
</html>